package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.pubapp.pub.rule.ApproveStatusCheckRule;
import nc.bs.test2.inhome.ace.rule.GoodsWriteBackRule;
import nc.bs.test2.inhome.plugin.bpplugin.InhomePluginPoint;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.itf.test2.IInhomeMaintain;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.test2.inhome.AggInhomeHVO;

public class N_CH02_APPROVE extends AbstractPfAction<AggInhomeHVO> {

	public N_CH02_APPROVE() {
		super();
	}

	@Override
	protected CompareAroundProcesser<AggInhomeHVO> getCompareAroundProcesserWithRules(
			Object userObj) {
		CompareAroundProcesser<AggInhomeHVO> processor = new CompareAroundProcesser<AggInhomeHVO>(
				InhomePluginPoint.APPROVE);
		processor.addBeforeRule(new ApproveStatusCheckRule());
		processor.addAfterRule(new GoodsWriteBackRule());
		return processor;
	}

	@Override
	protected AggInhomeHVO[] processBP(Object userObj,
			AggInhomeHVO[] clientFullVOs, AggInhomeHVO[] originBills) {
		AggInhomeHVO[] bills = null;
		IInhomeMaintain operator = NCLocator.getInstance().lookup(
				IInhomeMaintain.class);
		try {
			bills = operator.approve(clientFullVOs, originBills);
		} catch (BusinessException e) {
			ExceptionUtils.wrappBusinessException(e.getMessage());
		}
		return bills;
	}

}
